Classes as Assertions
نویسنده
چکیده
How do we formally specify the relation between a base class and a derived class? This question has two parts, a syntactic one, and a semantic one. The syntactic part is of course the easier of the two and the answer to that part is the standard contra/covariance requirement on the arguments and result of any base class method redefined in the derived class. Our concern in the current paper is with the semantic part of the question, i.e., how do we specify the behavioral relation between the base class and the derived class? We show that the standard answer –which is the semantic counterpart of contra/co-variance– is too rigid, and does not allow some natural and common forms of inheritance. We then propose a more flexible way to specify the relation, and show how different types of behavioral relations between base classes and derived classes may be specified using our notation.
منابع مشابه
Polymorphism in Object-Oriented Contract Verification
The role that design by contract plays in the specification, monitoring, and reuse of classes is of increasing importance in the OO community. Although recognizably useful, nevertheless, because of lack of expressiveness of existing assertion languages, contracts can bring undesirable effects such as the increasing in class coupling when we deal with complex classes. A means of surpassing those...
متن کاملDesign by Contract Using Meta-Assertions
The important role that class contracts Ð pre and post-conditions of methods, and invariants Ð play in the specification, monitoring and reuse of classes is becoming increasingly accepted by the OO community. The several languages of assertions and monitoring code generation tools that exist allow the specification and, eventually, the runtime checking of very powerful and elegant contracts. Th...
متن کاملContracts: From Analysis to C++ Implementation
Standard C++ does not provide mechanisms for working with assertions in the spirit of design by contract (DBC) as proposed by Meyer. We earlier developed a set of techniques and tools facilitating the prototyping of object-oriented architectures based on the idea of design by contract. As it is crucial for us to support evolutionary prototyping, we need to provide mechanisms to automatically tr...
متن کاملA Library-Based Approach to Translating OCL Constraints to JML Assertions for Runtime Checking
OCL is a formal notation to specify constraints on UML models that cannot otherwise be expressed by diagrammatic notations such as class diagrams. Using OCL one can document detailed design decisions and choices along with the behavior, e.g., class invariants and method pre and postconditions. However, OCL constraints cannot be directly executed and checked at runtime by an implementation, thus...
متن کاملA Variable Typed Logic of E ects
In this paper we introduce a variable typed logic of eeects inspired by the variable type systems of Feferman for purely functional languages. VTLoE (Variable Typed Logic of EEects) is introduced in two stages. The rst stage is the rst-order theory of individuals built on assertions of equality (operational equivalence a la Plotkin), and contextual assertions. The second stage extends the logic...
متن کاملExtending a Method of Devising Software Contracts
Classes in object-oriented programs can be specified using assertions, specifically, preconditions and postconditions on individual methods and invariants on whole classes. Such assertions can be seen as forming a contract between a class and its client classes and, by extension, between the developers of a class and the developers of client classes. In some programming environments, the contra...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1996